public class SumMax {
    public int sum(int n[]) {
        int max = 0;
        for (int i = 0; i < n.length; i++) {
            int sum = 0;
            for (int j = i; j < n.length; j++) {
                sum = sum + n[j];
                if (sum > max) {
                    max = sum;
                }
            }
        }
        System.out.println("整数数组中子数组之和的最大值为："+max);
        return max;

    }
}
